package com.sea.physical.controller;




import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {

        // 顶层对象
        JSONObject root = new JSONObject();
        root.put("access_token", "78e68d9d88d6b52cf10f00f7267bbfd7");
        root.put("userid", "1100795470840750109");
        root.put("workflowId", "1100425180250833131");

        // formData 对象
        JSONObject formData = new JSONObject();
        JSONArray dataDetails = new JSONArray();

        // 构造 dataDetails 中的每一项
        JSONObject item1 = new JSONObject();
        item1.put("content", "正润");
        item1.put("dataKey", "gys");

        JSONObject item2 = new JSONObject();
        item2.put("content", "ykj-柜号");
        item2.put("dataKey", "jh");

        JSONObject item3 = new JSONObject();
        item3.put("content", "2025-04-01");
        item3.put("dataKey", "zjrq");

        // 带 dataOptions 的项
        JSONObject item4 = new JSONObject();
        item4.put("content", "附件上传");
        item4.put("dataKey", "cyjhmx");

        // dataOptions 是数组
        JSONArray dataOptions = new JSONArray();
        JSONObject option = new JSONObject();
        option.put("content", "图片");
        option.put("optionId", "1117499814286180381");
        option.put("type", "file");

        dataOptions.add(option);
        item4.put("dataOptions", dataOptions);

        // 添加所有 items 到 dataDetails
        dataDetails.add(item1);
        dataDetails.add(item2);
        dataDetails.add(item3);
        dataDetails.add(item4);

        formData.put("dataDetails", dataDetails);
        root.put("formData", formData);

        // 输出完整 JSON
        System.out.println("构造后的 JSON：");
        System.out.println(root.toJSONString());
    }
}
